package com.atguigu.jxc.controller;

import com.atguigu.jxc.annotation.Log;
import com.atguigu.jxc.entity.CustomerReturnList;
import com.atguigu.jxc.service.CustomerReturnListService;
import com.atguigu.jxc.to.CustomerCountTo;
import com.atguigu.jxc.to.ReturnCountTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: lshuaib
 * @create: 2021-03-08 15:10
 * @description:
 */
@RestController
@RequestMapping("/customerReturnListGoods")
public class CustomerReturnListController {
    @Autowired
    CustomerReturnListService customerReturnListService;

    /**
     * 保存回退单
     *
     * @param returnNumber
     * @param customerReturnList
     * @param
     * @param httpSession
     * @return
     */
    @PostMapping("/save")
    public Map<String, Object> save(@RequestParam("returnNumber") String returnNumber,
                                    CustomerReturnList customerReturnList,
                                    String customerReturnListGoodsStr,
                                    HttpSession httpSession) {
        Map<String,Object> map=new HashMap<>();

        try {
            customerReturnListService.save(returnNumber, customerReturnList, customerReturnListGoodsStr, httpSession);
            map.put("code", 100);
            map.put("msg", "请求成功");
            map.put("info", null);
            return map;
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }


    /**
     * @Description: //TODO 客户退货统计（可根据 商品类别、商品编码或名称 条件查询）
     * @Param: []
     * @return: com.atguigu.jxc.domain.ServiceVO
     * @Version: 1.0
     * @Date: 2021/3/8 10:27
     * @Author: HanSan·胡
     **/
    @Log(logType = "查询操作",logContent = "客户退货统计")
    @PostMapping("/count")
    public List<Map> count(CustomerCountTo customerCountTo){
        return customerReturnListService.count(customerCountTo);
    }




}
